//package com.zmn.plat.dubbo.impl.channel;
//
//import com.zmn.common.constant.GlobalConsts;
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.common.utils.collection.CollectionUtil;
//import com.zmn.common.utils.string.StringUtil;
//import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
//import com.zmn.plat.business.interfaces.pilot.ChannelPriceBService;
//import com.zmn.plat.common.constant.BaseCodeMapConsts;
//import com.zmn.plat.common.constant.OnePriceConsts;
//import com.zmn.plat.common.dictionary.WhitelistUserTypeEnum;
//import com.zmn.plat.common.dto.pilot.PilotEarnesPriceDRO;
//import com.zmn.plat.common.enums.PilotConfigEnum;
//import com.zmn.plat.common.exception.PlatException;
//import com.zmn.plat.dubbo.interfaces.channel.ChannelOnePriceListRemoteService;
//import com.zmn.plat.dubbo.utils.DubboConsts;
//import com.zmn.plat.model.entity.pilot.ChannelPrice;
//import com.zmn.plat.model.entity.pilot.ChannelPriceQuery;
//import com.zmn.plat.model.entity.product.BaseCodeMap;
//import com.zmn.plat.model.entity.product.BaseCodeMapQuery;
//import com.zmn.plat.services.interfaces.area.BaseAreaService;
//import com.zmn.plat.services.interfaces.pilot.ChannelPriceService;
//import com.zmn.plat.services.interfaces.product.BaseCodeMapService;
//import lombok.extern.log4j.Log4j2;
//import org.apache.dubbo.config.annotation.Service;
//
//import javax.annotation.Resource;
//import java.util.List;
//import java.util.Map;
//
///**
// * 渠道城市一口价
// *
// * @author xiangjunming
// * @since 2019/11/28 14:46:29
// */
//@Log4j2
//@Service(version = DubboConsts.INTERFACE_VERSION, validation = "true")
//public class ChannelOnePriceListRemoteServiceImpl implements ChannelOnePriceListRemoteService {
//
//    @Resource
//    private ChannelPriceBService channelPriceBService;
//
//    @Resource
//    BaseCodeMapService baseCodeMapService;
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<Boolean> checkSupportOnePriceByChannelIdAndCityId(Integer channelId, Integer cityId) {
//
//        log.info(
//                "ChannelOnePriceListRemoteServiceImpl.checkSupportOnePriceByChannelIdAndCityId参数channelId：{}，cityId：{}",
//                channelId, cityId);
//        try {
//            Boolean isSupport = channelPriceBService.checkByChannelIdAndCityIdAndTypeAndCateg(channelId, cityId,
//                                                                                              OnePriceConsts.ONE_PRICE,
//                                                                                              null, null);
//            return ResponseDTO.success(isSupport);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("checkSupportOnePriceByChannelIdAndCityId系统异常", e);
//            return ResponseDTO.fail(GlobalConsts.FAILD_MSG);
//        }
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<Boolean> checkSupportByChannelIdAndCityIdAndType(Integer channelId, Integer cityId, Integer type) {
//        log.info("ChannelOnePriceListRemoteServiceImpl.checkSupportByChannelIdAndCityIdAndType参数channelId：{}，cityId：{}，type：{}", channelId, cityId, type);
//        try {
//            Boolean isSupport = channelPriceBService.checkByChannelIdAndCityIdAndTypeAndCateg(channelId, cityId, type, null, null);
//            return ResponseDTO.success(isSupport);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("checkSupportByChannelIdAndCityIdAndType系统异常", e);
//            return ResponseDTO.fail(GlobalConsts.FAILD_MSG);
//        }
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<Boolean> checkSupportByChannelIdAndCityIdAndTypeAndCategId(Integer channelId, Integer cityId, Integer type,
//        Integer servCategId, Integer categId) {
//        log.info("ChannelOnePriceListRemoteServiceImpl.checkSupportByChannelIdAndCityIdAndTypeAndCategId参数channelId：{}，cityId：{}，type：{}，servCategId：{}，categId：{}", channelId, cityId, type, servCategId, categId);
//        try {
//            Boolean isSupport = channelPriceBService.checkByChannelIdAndCityIdAndTypeAndCateg(channelId, cityId, type, servCategId, categId);
//            return ResponseDTO.success(isSupport);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("checkSupportByChannelIdAndCityIdAndTypeAndCategId系统异常", e);
//            return ResponseDTO.fail(GlobalConsts.FAILD_MSG);
//        }
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<Boolean> checkSupportByChannelIdAndCityIdAndTypeAndProductId(Integer channelId, Integer cityId, Integer type,
//        Integer showProductId) {
//        return checkSupportByChannelIdAndCityIdAndTypeAndProductId(channelId, cityId, type, null, showProductId);
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<Boolean> checkSupportByChannelIdAndCityIdAndTypeAndProductId(Integer channelId, Integer cityId, Integer type,
//        Integer productId, Integer showProductId) {
//        log.info("checkSupportByChannelIdAndCityIdAndTypeAndProductId参数: channelId:{}, cityId:{}, type: {}, productId:{}, showProductId{}", channelId, cityId, type,
//                productId, showProductId);
//        try {
//            boolean supoort =
//                    channelPriceBService.checkByChannelIdAndCityIdAndTypeAndProductId(channelId, cityId, type, productId, showProductId);
//            return ResponseDTO.success(supoort);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("checkSupportByChannelIdAndCityIdAndTypeAndProductId系统异常", e);
//            return ResponseDTO.fail(GlobalConsts.FAILD_MSG);
//        }
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<Map<Integer, Boolean>> checkTariffAndAdvance(Integer channelId, Integer cityId, List<Integer> showProductIdList) {
//        log.info("checkTariffAndAdvance参数: channelId:{}, cityId:{}, showProductIdList: {}", channelId, cityId, showProductIdList);
//        try {
//            Map<Integer, Boolean> booleanMap = channelPriceBService.checkTariffAndAdvance(channelId, cityId, showProductIdList);
//            return ResponseDTO.success(booleanMap);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("checkTariffAndAdvance系统异常", e);
//            return ResponseDTO.fail();
//        }
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<PilotEarnesPriceDRO>> listPilotEarnesPrice(Integer channelId, Integer cityId,  List<Integer> showProductIdList) {
//        try {
//            List<PilotEarnesPriceDRO> pilotEarnesPriceDROS = channelPriceBService.listPilotEarnesPrice(channelId, cityId, showProductIdList);
//            return ResponseDTO.success(pilotEarnesPriceDROS);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("getPilotEarnesPrice异常", e);
//            return ResponseDTO.fail();
//        }
//    }
//
//
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<Boolean> checkSupportAndWhitelistByChannelIdAndCityIdAndTypeAndCategId(Integer channelId,
//                                                                                              Integer cityId,
//                                                                                              Integer servCategId,
//                                                                                              Integer categId,
//                                                                                              Integer userType,
//                                                                                              String userId) {
//
//        try {
//            log.info("===========checkSupportAndWhitelistByChannelIdAndCityIdAndTypeAndCategId" +
//                     ":参数输出==========channelId:{},cityId:{},servCategId:{},categId={},userType={},userId={}",
//                     channelId, cityId, servCategId, categId, userType, userId);
//            // 先判断是否有白名单
//            BaseCodeMapQuery query = new BaseCodeMapQuery();
//            query.setOneTypeId(BaseCodeMapConsts.BASE_CODE_MAP_ONE_TYPE_NUMBER_WHITELIST);
//            if (WhitelistUserTypeEnum.STAFF_WHITELIST.getCode().equals(userType)) {
//
//                query.setTwoTypeId(BaseCodeMapConsts.BASE_CODE_MAP_ONE_TYPE_NUMBER_STAFF_WHITELIST);
//            } else {
//                query.setTwoTypeId(BaseCodeMapConsts.BASE_CODE_MAP_ONE_TYPE_NUMBER_MASTER_WHITELIST);
//            }
//            query.setStatus(GlobalConsts.YES);
//            List<BaseCodeMap> baseCodeMaps = baseCodeMapService.listByQuery(query);
//            log.info("========查询白名单：{}=======", baseCodeMaps);
//            if (CollectionUtil.isNotNullOrEmpty(baseCodeMaps) && StringUtil.isNotBlank(baseCodeMaps.get(0).getName())) {
//                boolean contains = baseCodeMaps.get(0).getName().contains(userId);
//                log.info("白名单校验：{}", contains);
//                // 不在白名单中
//                if (!contains){
//                    return ResponseDTO.success(false);
//                }
//            }
//
//            // 若没有白名单 或者 用户在白名单中
//            Boolean isSupport = channelPriceBService
//                    .checkByChannelIdAndCityIdAndTypeAndCateg(channelId, cityId, PilotConfigEnum.REPAIR_ROBOT.getType(),
//                                                              servCategId, categId);
//
//            if (isSupport) {
//                log.info("维修机器人试点校验：{}", isSupport);
//                return ResponseDTO.success(true);
//            }
//
//            return ResponseDTO.success(channelPriceBService.listPilotOpen(channelId, cityId,
//                                                                          PilotConfigEnum.REPAIR_ROBOT.getType()));
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("checkSupportAndWhitelistByChannelIdAndCityIdAndTypeAndCategId", e);
//            return ResponseDTO.fail(GlobalConsts.FAILD_MSG);
//        }
//    }
//
//}
